import org.apache.kudu.client.*;

//Kudu API更新数据
public class UpdateDemo {
    public static void main(String[] args) {
        //获取客户端
        KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder("linux121");
        builder.defaultSocketReadTimeoutMs(5000);
        KuduClient client = builder.build();

        try {
            //打开一张表
            KuduTable student = client.openTable("student");
            //创建会话
            KuduSession session = client.newSession();
            //设置刷新模式
            session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
            //获取更新实例
            Update update = student.newUpdate();
            //声明待更新数据
            update.getRow().addInt("id", 1);
            update.getRow().addString("name", "xiaoming");
            //应用更新实例
            session.apply(update);
            //关闭会话
            session.close();
        } catch (KuduException e) {
            e.printStackTrace();
        } finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }
    }
}
